#include <iostream>

#include "gtest/gtest.h"
#include "ClientApi.h"
#include <memory>
#include "Log.h"
#include <vector>
#include <boost/filesystem.hpp>

static boost::shared_ptr<CSApi::ClientApi> api;

#define STORAGE_NAME "Storage"

class Folder : public ::testing::Test {
	protected:

		static void SetUpTestCase()	{
			FUNCTION_TRACK
			ASSERT_NO_THROW({
				api = CSApi::CreateClientApi("127.0.0.1", "5001", "root", "root");
				boost::filesystem::create_directories("/tmp/Folder");
                boost::filesystem::create_directories("/tmp/Folder/Folder");
			});
            ASSERT_TRUE(api.get() != NULL);
            FILE *f = fopen("/tmp/Folder/found.txt", "w");
            ASSERT_TRUE(f != NULL);
            fprintf(f, "TEST");
            fclose(f);

            f = fopen("/tmp/Folder/found-deleteme.txt", "w");
            ASSERT_TRUE(f != NULL);
            fprintf(f, "TEST");
            fclose(f);
			ASSERT_NO_THROW({
				ASSERT_TRUE(api->Share("/FolderTests", "/tmp/Folder", STORAGE_NAME));
                ASSERT_TRUE(api->Share("/FolderTests-found.txt", "/tmp/Folder/found.txt", STORAGE_NAME));
			});
		}

		static void TearDownTestCase() {
			ASSERT_NO_THROW({
				api.reset();
                boost::filesystem::remove_all("/tmp/Folder");
			});
		}
};

